/**
 * Copyright (c) 2023 OceanBase
 * OceanBase CE is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

// This autogenerated skeleton file illustrates how to build a server.
// You should copy it to another filename to avoid overwriting it.

#include "FacebookService.h"
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>

using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace ::apache::thrift::server;

using namespace  ::facebook::fb303;

class FacebookServiceHandler : virtual public FacebookServiceIf {
 public:
  FacebookServiceHandler() {
    // Your initialization goes here
  }

  /**
   * Returns a descriptive name of the service
   */
  void getName(std::string& _return) {
    // Your implementation goes here
    printf("getName\n");
  }

  /**
   * Returns the version of the service
   */
  void getVersion(std::string& _return) {
    // Your implementation goes here
    printf("getVersion\n");
  }

  /**
   * Gets the status of this service
   */
  fb_status::type getStatus() {
    // Your implementation goes here
    printf("getStatus\n");
  }

  /**
   * User friendly description of status, such as why the service is in
   * the dead or warning state, or what is being started or stopped.
   */
  void getStatusDetails(std::string& _return) {
    // Your implementation goes here
    printf("getStatusDetails\n");
  }

  /**
   * Gets the counters for this service
   */
  void getCounters(std::map<std::string, int64_t> & _return) {
    // Your implementation goes here
    printf("getCounters\n");
  }

  /**
   * Gets the value of a single counter
   *
   * @param key
   */
  int64_t getCounter(const std::string& key) {
    // Your implementation goes here
    printf("getCounter\n");
  }

  /**
   * Sets an option
   *
   * @param key
   * @param value
   */
  void setOption(const std::string& key, const std::string& value) {
    // Your implementation goes here
    printf("setOption\n");
  }

  /**
   * Gets an option
   *
   * @param key
   */
  void getOption(std::string& _return, const std::string& key) {
    // Your implementation goes here
    printf("getOption\n");
  }

  /**
   * Gets all options
   */
  void getOptions(std::map<std::string, std::string> & _return) {
    // Your implementation goes here
    printf("getOptions\n");
  }

  /**
   * Returns a CPU profile over the given time interval (client and server
   * must agree on the profile format).
   *
   * @param profileDurationInSec
   */
  void getCpuProfile(std::string& _return, const int32_t profileDurationInSec) {
    // Your implementation goes here
    printf("getCpuProfile\n");
  }

  /**
   * Returns the unix time that the server has been running since
   */
  int64_t aliveSince() {
    // Your implementation goes here
    printf("aliveSince\n");
  }

  /**
   * Tell the server to reload its configuration, reopen log files, etc
   */
  void reinitialize() {
    // Your implementation goes here
    printf("reinitialize\n");
  }

  /**
   * Suggest a shutdown to the server
   */
  void shutdown() {
    // Your implementation goes here
    printf("shutdown\n");
  }

};

int main(int argc, char **argv) {
  int port = 9090;
  ::std::shared_ptr<FacebookServiceHandler> handler(new FacebookServiceHandler());
  ::std::shared_ptr<TProcessor> processor(new FacebookServiceProcessor(handler));
  ::std::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
  ::std::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
  ::std::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());

  TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
  server.serve();
  return 0;
}
